home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / test / sh1 < prev    next >
Text File  |  1990-07-23  |  7KB  |  308 lines

  1. # Shell script used to test MINIX.[T
  2.  
  3. echo -n "Shell test  1 "
  4. rm -rf testdir
  5. mkdir testdir
  6. cd testdir
  7.  
  8. f=../test0.c
  9. if test -r $f; then : ; else echo sh1 cannot read $f; exit 1; fi
  10.  
  11. #Initial setup
  12. echo "abcdefghijklmnopqrstuvwxyz" >alpha
  13. echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ" >ALPHA
  14. echo "0123456789" >num
  15. echo "!@#$%^&*()_+=-{}[]:;<>?/.," >special
  16. cp /etc/rc rc
  17. cp /etc/passwd passwd
  18. cat alpha ALPHA num rc passwd special >tmp
  19. cat tmp tmp tmp >f1
  20.  
  21.  
  22. #Test cp
  23. mkdir foo
  24. cp /etc/rc /etc/passwd foo
  25. if cmp -s foo/rc /etc/rc ; then : ; else echo Error on cp test 1; fi
  26. if cmp -s foo/passwd /etc/passwd ; then : ; else echo Error on cp test 2; fi
  27. rm -rf foo
  28.  
  29. #Test cat
  30. cat num num num num num >y
  31. wc -c y >x1
  32. echo "     55 y" >x2
  33. if cmp -s x1 x2; then : ; else echo Error on cat test 1; fi
  34. cat <y >z
  35. if cmp -s y z; then : ; else echo Error on cat test 2; fi
  36.  
  37. #Test ar
  38. cat passwd >p
  39. cp passwd q
  40. if cmp -s p q; then : ; else echo Error on ar test 1; fi
  41. date >r
  42. ar r x.a p q r 2>/dev/null
  43. ar r x.a /bin/cp
  44. # ar syntax is different for IBM and 68000
  45. if chip INTEL;  then ar rb p x.a /bin/cat; fi
  46. if chip M68000; then ar r x.a /bin/cat; fi
  47. rm p q
  48. mv r R
  49. ar x x.a
  50. if cmp -s p /etc/passwd; then : ; else Error on ar test 2; fi
  51. if cmp -s q /etc/passwd; then : ; else Error on ar test 3; fi
  52. if cmp -s r R; then : ; else Error on ar test 4; fi
  53. if cmp -s cp /bin/cp; then : ; else Error on ar test 5; fi
  54. if cmp -s cat /bin/cat; then : ; else Error on ar test 6; fi
  55. rm cp cat p q r
  56. ar d x.a r
  57. ar x x.a
  58. if test -r r; then echo Error on ar test 7; fi
  59. rm -rf p q r R
  60.  
  61. #Test basename
  62. if test `basename /usr/ast/foo.c .c` != 'foo'
  63.    then echo Error on basename test 1
  64. fi
  65.  
  66. if test `basename a/b/c/d` != 'd'; then Error on basename test 2; fi
  67.  
  68. #Test cdiff, sed, and patch
  69. cp $f x.c            # x.c is a copy $f
  70. echo "/a/s//#####/g" >s        # create sed script
  71. sed -f s <x.c >y.c        # y.c is new version of x.c
  72. cdiff x.c y.c >y        # y is cdiff listing
  73. patch x.c y  2>/dev/null    # z should be y.c
  74. if cmp -s x.c y.c; then : ; else echo Error in cdiff test; fi
  75. rm x.c* y.c s y
  76.  
  77. #Test comm, grep -v
  78. ls /etc >x            # x = list of /etc
  79. grep -v "passwd" x >y        # y = x except for /etc/passwd
  80. comm -3 x y >z            # should only be 1 line, /etc/passwd
  81. echo "passwd" >w
  82. if cmp -s w z; then : else echo Error on comm test 1; fi
  83.  
  84. comm -13 x y >z            # should be empty
  85. if test -s z; then echo Error on comm test 2; fi
  86. rm -rf w x y z
  87.  
  88. #Test compress
  89. compress -fc $f >x.c.Z        # compress the test file
  90. compress -cd x.c.Z >y        # uncompress it
  91. if cmp -s $f y; then : else echo Error in compress test 1; fi
  92. rm -rf x.c.Z y
  93.  
  94. #Test ed
  95. cp $f x                # copy $f to x
  96. cat >y <<END
  97. g/a/s//#####/g
  98. g/b/s//@@@@@/g
  99. g/c/s//!!!!!/g
  100. w
  101. q
  102. END
  103. ed x <y >/dev/null
  104. cat >y <<END
  105. g/#####/s//a/g
  106. g/@@@@@/s//b/g
  107. g/!!!!!/s//c/g
  108. w
  109. q
  110. END
  111. ed x <y >/dev/null
  112. if cmp -s x $f; then : ; else echo Error in ed test 1; fi
  113. rm x y
  114.  
  115. #Test expr
  116. if test `expr 1 + 1` != 2; then echo Error on expr test 1; fi
  117. if test `expr 10000 - 1` != 9999; then echo Error on expr test 2; fi
  118. if test `expr 100 '*' 50` != 5000; then echo Error on expr test 3; fi
  119. if test `expr 120 / 5` != 24; then echo Error on expr test 4; fi
  120. if test `expr 143 % 7` != 3; then echo Error on expr test 5; fi
  121. a=100
  122. a=`expr $a + 1`
  123. if test $a != '101'; then echo Error on expr test 6; fi
  124.  
  125. #Test fgrep
  126. fgrep "abc" alpha >z
  127. if cmp -s alpha z ; then : else echo Error on fgrep test 1; fi
  128. fgrep "abc" num >z
  129. if test -s z; then echo Error on fgrep test 2; fi
  130. cat alpha num >z
  131. fgrep "012" z >w
  132. if cmp -s w num; then : ; else echo Error fgrep test 3; fi
  133.  
  134.  
  135. #Test find
  136. date >Rabbit
  137. echo "Rabbit" >y
  138. find . -name Rabbit -print >z
  139. if cmp -s y z; then : else echo Error on find test 1; fi
  140. find . -name Bunny -print >z
  141. if test -s z; then echo Error on find test 2; fi
  142. rm Rabbit y z
  143.  
  144. #Test grep
  145. grep "a" alpha >x
  146. if cmp -s x alpha; then : ; else echo Error on grep test 1; fi
  147. grep "a" ALPHA >x
  148. if test -s x; then echo Error on grep test 2; fi
  149. grep -v "0" alpha >x
  150. if cmp -s x alpha; then : ; else echo Error on grep test 3; fi
  151. grep -s "a" alpha >x
  152. if test -s x; then echo Error on grep test 4; fi
  153. if grep -s "a" alpha >x; then : else echo Error on grep test 5; fi
  154. if grep -s "a" ALPHA >x; then echo Error on grep test 6; fi
  155.  
  156. #Test head
  157. head -1 f1 >x
  158. if cmp -s x alpha; then : else echo Error on head test 1; fi
  159. head -2 f1 >x
  160. cat alpha ALPHA >y
  161. if cmp -s x y; then : else echo Error on head test 2; fi
  162.  
  163. #Test ls
  164. mkdir FOO
  165. cp passwd FOO/z
  166. cp alpha FOO/x
  167. cp ALPHA FOO/y
  168. cd FOO
  169. ls >w
  170. cat >w1 <<END
  171. w
  172. x
  173. y
  174. z
  175. END
  176. if cmp -s w w1; then : ; else echo Error on ls test 1; fi
  177. rm *
  178. cd ..
  179. rmdir FOO
  180.  
  181. #Test mkdir/rmdir
  182. mkdir Foo Bar
  183. if test -d Foo; then : ; else echo Error on mkdir test 1; fi
  184. if test -d Bar; then : ; else echo Error on mkdir test 2; fi
  185. rmdir Foo Bar
  186. if test -d Foo; then echo Error on mkdir test 3; fi
  187. if test -d Foo; then echo Error on rmdir test 4; fi
  188.  
  189. #Test mv
  190. mkdir MVDIR
  191. cp $f x
  192. mv x y
  193. mv y z
  194. if cmp -s $f z; then : ; else echo Error on mv test 1; fi
  195. cp $f x
  196. mv x MVDIR/y
  197. if cmp -s $f MVDIR/y; then : ; else echo Error on mv test 2; fi
  198.  
  199. #Test rev
  200. rev <f1 | head -1 >ahpla
  201. echo "zyxwvutsrqponmlkjihgfedcba" >x
  202. if cmp -s x ahpla; then : ; else echo Error on rev test 1; fi
  203. rev <$f >x
  204. rev <x >y
  205. if cmp -s $f x; then echo Error on rev test 2; fi
  206. if cmp -s $f y; then : ; else echo error on rev test 3; fi
  207.  
  208. #Test shar
  209. cp $f w
  210. cp alpha x
  211. cp ALPHA y
  212. cp num z
  213. shar w x y z >x1
  214. rm w x y z
  215. sh <x1 >/dev/null
  216. if cmp -s w $f; then : ; else echo Error on shar test 1; fi
  217. if cmp -s x alpha; then : ; else echo Error on shar test 2; fi
  218. if cmp -s y ALPHA; then : ; else echo Error on shar test 3; fi
  219. if cmp -s z num; then : ; else echo Error on shar test 4; fi
  220.  
  221. #Test sort
  222. sort <$f >x
  223. wc <$f >x1
  224. wc <x >x2
  225. if cmp -s x1 x2; then : ; else echo Error on sort test 1; fi
  226. cat >x <<END
  227. demit 10
  228. epitonic 40
  229. apoop 20
  230. bibelot 3
  231. comate 4
  232. END
  233. cat >y <<END
  234. apoop 20
  235. bibelot 3
  236. comate 4
  237. demit 10
  238. epitonic 40
  239. END
  240. cat >z <<END
  241. epitonic 40
  242. demit 10
  243. comate 4
  244. bibelot 3
  245. apoop 20
  246. END
  247. sort <x >x1
  248. if cmp -s y x1; then : ; else echo Error on sort test 2; fi
  249. sort -r <x1 >x2
  250. if cmp -s x2 z; then : ; else echo Error on sort test 3; fi
  251. sort +1 -n <x |head -1 >y
  252. echo "bibelot 3" >z
  253. if cmp -s y z; then : ; else echo Error on sort test 4; fi
  254.  
  255. #Test tail
  256. tail -1 f1 >x
  257. if cmp -s x special; then : ; else echo Error on tail test 1; fi
  258.  
  259. #Test tsort
  260. cat >x <<END
  261. a d
  262. b e
  263. c f
  264. a c
  265. p z
  266. k p
  267. a k
  268. a b
  269. b c
  270. c d
  271. d e
  272. e f
  273. f k
  274. END
  275. cat >answer <<END
  276. a
  277. b
  278. c
  279. d
  280. e
  281. f
  282. k
  283. p
  284. z
  285. END
  286. tsort <x >y
  287. if cmp -s y answer; then : ; else echo Error on tsort test 1; fi
  288.  
  289. #Test uue/uud
  290. cp $f x
  291. uue x
  292. if test -s x.uue; then : ; else echo Error on uue/uud test 1; fi
  293. rm x
  294. uud x.uue
  295. if cmp -s x $f; then : ; else echo Error on uue/uud test 2; fi
  296.  
  297. compress -fc x >x.Z 2>/dev/null
  298. uue x.Z
  299. rm x x.Z
  300. uud x.uue
  301. compress -cd x.Z >x
  302. if cmp -s x $f; then : ; else echo Error on uue/uud test 3; fi
  303.  
  304. cd ..
  305. rm -rf testdir
  306.  
  307. echo ok
  308.